package com.shop2cn.iapi.wxcomponent.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.google.gson.JsonObject;
import com.shop2cn.iapi.wxcomponent.parameter.GetPlatformConfigBean;
import com.shop2cn.iapi.wxcomponent.service.GetPlatformConfigCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.database.model.Mchapp;
import com.ymttest.database.model.Platformconfig;
import com.ymttest.database.sqlwapper.godmch.DefGodMchWapper;
/**
*查询平台appid和token
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_GetPlatformConfig{
	private static GetPlatformConfigBean getplatformconfigBean;
	private static GetPlatformConfigCall getplatformconfigCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("查询平台appid和token");
	}

	@Before
	public void caseUp() {
		getplatformconfigBean=new GetPlatformConfigBean();
		getplatformconfigCall=new GetPlatformConfigCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getplatformconfigCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetPlatformConfig_001() {
		Logger.start(true,"查询平台appid和token");
		try {
			DefGodMchWapper DefGodMchWapper=new DefGodMchWapper();
			 Platformconfig defplatform = DefGodMchWapper.selectPlatformconfigByExample().get(0);
			getplatformconfigCall.setData(getplatformconfigBean);
			getplatformconfigCall.callService();			
			Logger.verifyEquals("200", getplatformconfigCall.getString("code"), "验证返回code");
			JsonObject ja = getplatformconfigCall.getJsonObject().get("data").getAsJsonObject();
			Logger.verifyEquals(ja.get("platformAppId").getAsString(),defplatform.getPlatformAppId(), "验证返回platformAppId");
			Logger.verifyEquals(ja.get("accessToken").getAsString(),defplatform.getAccessToken(), "验证返回accessToken");
			Logger.verifyEquals(ja.get("verifyTicket").getAsString(),defplatform.getVerifyTicket(), "验证返回verifyTicket");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}